// pages/index/index.js
const APP = getApp();

Page({

    /**
     * 页面的初始数据
     */
    data: {
        //轮播图
        dataSwiperCurrent:0,
        dataBanners:[],
        //功能块
        dataActions:[
            {
                name: '功能',
                icon: '/pages/res/owner/icon_list_item2.png',
                link: '/pages/index/sub/expert-list',
                open_type:'navigate',
                extra_data:{}
              },
              {
                name: '功能',
                icon: '/pages/res/owner/icon_list_item2.png',
                link: '/pages/index/sub/device-list',
                open_type:'navigate',
                extra_data:{}
              },
              {
                name: '功能',
                icon: '/pages/res/owner/icon_list_item2.png',
                link: '/pages/owner/sub/learn-list',
                open_type:'navigate',
                extra_data:{}
              },
              {
                name: '功能',
                icon: '/pages/res/owner/icon_list_item2.png',
                link: '/pages/index/sub/device-list',
                open_type:'navigate',
                extra_data:{}
              },
              {
                name: '功能',
                icon: '/pages/res/owner/icon_list_item2.png',
                link: '/pages/owner/sub/learn-list',
                open_type:'navigate',
                extra_data:{}
              },
        ],
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        let _this = this;
        //控制权限
        APP.appauth.setAuthSetting();
        this.init();
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    },

    // ====================【逻辑区域】====================

    /**初始化 */
    init(){
        let _this = this;
        APP._post('/Data/banners', {}, false, function (resData) {
            //执行成功
            _this.setData({
                dataBanners:resData.list,
            });
        }, function (res) {
            //执行失败
        }, function (res) {
            //执行完成
        });
    },
    /**事件 */
    bindSwiperChange: function (eventhandle){
        let tmpDetail = eventhandle.detail; //event.detail={current, source}
        // this.data.dataSwiperCurrent = tmpDetail.current;
        //禁止使用以下代码
        this.setData({
          dataSwiperCurrent: tmpDetail.current
        })
    },
    
})